﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class PlayerHealth : MonoBehaviour
{
    private int trapsLayer;
    public GameObject deathVFXPrefab;
    public GameObject deathTips;

    private void Start()
    {
        trapsLayer = LayerMask.NameToLayer("Traps");
    }

    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.layer == trapsLayer)
        {
            Instantiate(deathVFXPrefab,transform.position,transform.rotation);

            Invoke("DeaddTips",1f);

            gameObject.SetActive(false);

            AudioManager.PlayDeathAudio();

            GameManager.PlayerDied();
        }

    }

    void DeaddTips() 
    {
        Instantiate(deathTips, transform.position, Quaternion.Euler(0,0.8f,Random.Range(-15,15)));
    }
}
